﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Slja.BLL;
using Slja.Utility;
using FrameWork.Components;

namespace FrameWork.web.Web.UC
{
    public partial class PriceWork : OrderSectionBase
    {
        protected override void LoadData()
        {
            tlbPriceMemo.Text = Order.PriceMemo;
            fc_Price.Order = Order; fc_Price.LoadData();
        }
        public override void SaveData()
        {
             OrderBLL bll = new OrderBLL();
            //Order.DesignMemo = tlbDesignMemo.Text.Trim();
            //bll.UpdateDesignMemo(Order);
            bll.UpdateSingelField(Order.ID,new KeyValuePair<OrderField,string>(OrderField.PriceMemo,tlbPriceMemo.Text.Trim()));
        }

        protected override Components.OpRightState GetOpRight()
        {
            OpRightState opright = OpRightState.Readonly;
            if (Order.Enum_BackState == SaleState.PriceUp && //退回到 报价上传
               Order.CurOpUserID == Common.Get_UserID)
            {
                opright = OpRightState.Editable;
            }
            //未到”报价上传”
            if (Order.SaleStateLog < (int)SaleState.DesignConfirm)
            {
                opright = OpRightState.Hidden;
            }
            //正待”报价上传”
            else if ((Order.SaleStateLog == (int)(
                SaleState.NewOrder | SaleState.AssignWork | 
                SaleState.DesignUp | SaleState.DesignSend | SaleState.DesignConfirm)))//刚刚 项目管理员确认设计               
            {//检查当前用户
                if (Order.CurOpUserID == Common.Get_UserID)
                {
                    opright = OpRightState.Editable;
                }
                else
                {
                    opright = OpRightState.Hidden;
                }
            }
            else //已“报价上传”
            {
                opright = OpRightState.Readonly;
            }
            //针对打印，处理:编辑变为不可编辑;
            if (ControlUsage == DisplayUsage.PrintDisplay && opright == OpRightState.Editable)
            {
                opright = OpRightState.Readonly;
            }
            return opright;
        }
    }
}